function DateSelector({ selectedDate, onDateChange }) {
    const formatDate = (date) => {
        const year = date.getFullYear();
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        return `${year}-${month}-${day}`;
    };

    const handleDateChange = (e) => {
        const newDate = new Date(e.target.value);
        onDateChange(newDate);
    };

    return (
        <div className="date-selector">
            <h2>选择日期</h2>
            <input
                type="date"
                value={formatDate(selectedDate)}
                onChange={handleDateChange}
            />
        </div>
    );
}

export default DateSelector; 